package com.lemon.tuvi2015.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lemon.tuvi2015.R;

@SuppressLint("ResourceAsColor") 
public class CustomActionbar extends RelativeLayout{
	private LayoutInflater layoutInflater;
	RelativeLayout mActionLayout;
	RippleLayout actionLeft,actionRight;
	TextView textTitle;
	Context context;
	public CustomActionbar(final Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context = context;
		layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		mActionLayout = (RelativeLayout) layoutInflater.inflate(R.layout.actionbar, null);
		addView(mActionLayout);
		textTitle=(TextView) findViewById(R.id.action_title);
		actionLeft=(RippleLayout) findViewById(R.id.action_left);
		actionRight=(RippleLayout) findViewById(R.id.action_right);
	}
	
	public void setActionbar(String title,OnClickListener clickListenerLeft,OnClickListener clickListenerRight){
		textTitle.setText(title);
		actionLeft.setOnClickListener(clickListenerLeft);
		if(clickListenerRight!=null)
			actionRight.setVisibility(View.VISIBLE);
		actionRight.setOnClickListener(clickListenerRight);
	}
	
	public void setActionbar(int id,OnClickListener clickListenerLeft,OnClickListener clickListenerRight){
		textTitle.setText(context.getResources().getString(id));
		actionLeft.setOnClickListener(clickListenerLeft);
		if(clickListenerRight!=null)
			actionRight.setVisibility(View.VISIBLE);
		actionRight.setOnClickListener(clickListenerRight);
	}
}
